﻿@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@using Newtonsoft.Json
@model Arap
@{
    var order = ViewBag.Order as Order;
    var customer = ViewBag.Customer as Customer;
    var financeInvoice = ViewBag.FinanceInvoice as FinanceInvoice;
    var amount = ViewBag.Amount;
    var operationName = ViewBag.OperationName;
    var operationTime = ViewBag.OperationTime;
}
<section class="content-header">
    <h1>
        应收账款查询
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("YingshouQuery", "CustomerService")">应收账款查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null && order != null && customer != null && financeInvoice != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("UpdateArap", "FinanceCost")" method="post">
                        <input type="hidden" id="Id" name="Id" value="@Model.Id" />
                        <input type="hidden" id="Type" name="Type" value="@Model.Type" />
                        <div class="box-body">
                            <div id="json1-content" class="col-md-12">
                                <table class="footable table table-stripped table-bordered table-hover" id="footable">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                发票号
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                订单号
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                客户名称
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                应收金额
                                            </th>
                                            <th data-sort-ignore="true" class="col-md-2">
                                                实际收金额
                                            </th>
                                            @if (Model.Status == 1)
                                            {
                                                <th data-sort-ignore="true" class="col-md-2">
                                                    操作时间
                                                </th>
                                            }
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                查看开票
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody id="data1-content">
                                        <tr>
                                            <td>
                                                @if (Model.InvoiceType == 1)
                                                {
                                                    <input type="text" class="form-control" id="FinanceNumber" name="FinanceNumber" value="@Model.FinanceNumber">
                                                }
                                                else
                                                {
                                                    @Model.FinanceNumber
                                                }
                                            </td>
                                            <td>@order.Number</td>
                                            <td>@customer.Name</td>
                                            <td>
                                                @amount
                                                <input type="hidden" class="form-control okeydown" id="ShouldMoney" name="ShouldMoney" value="@amount" readonly="readonly">
                                            </td>
                                            <td>
                                                <input type="hidden" class="form-control okeydown" id="ActualMoney" name="ActualMoney" value="@Model.ActualMoney" readonly="readonly">
                                                @Model.ActualMoney
                                            </td>
                                            @if (Model.Status == 1)
                                            {
                                                <td>@Model.CreateTime</td>
                                            }
                                            <td>
                                                <span class="btn bg-blue btn-xs" onclick="duizhangQueryInfo('@Model.FinanceInvoiceId')">查看</span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                            <div id="json-content" class="col-md-12 ">
                                @*<input type="hidden" id="modalData" value="@financeInvoice.ProductData" readonly="readonly">*@
                                <table class="footable table table-stripped table-bordered table-hover" id="footable1">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                品名
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸宽-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸长-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                基本单位
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                数量
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                价格
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                增值税
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                金额
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true">
                                                累计金额
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody id="data-content">
                                        @if (financeInvoice.ProductData != null)
                                        {
                                            var products = JsonConvert.DeserializeObject<List<dynamic>>(financeInvoice.ProductData);
                                            foreach (var item in products)
                                            {
                                                var cumulativemoney = 0.00;
                                                if (item.CumulativeMoney != null)
                                                {
                                                    cumulativemoney = item.CumulativeMoney;
                                                }
                                                <tr class="tr">
                                                    <td>
                                                        @item.ProductName
                                                        <input type="hidden" class="form-control" data-des="产品Id" id="ProductId" name="ProductId" value="@item.ProductId">
                                                        <input type="hidden" class="form-control" data-des="品名" id="ProductName" name="ProductName" value="@item.ProductName">
                                                    </td>
                                                    <td>
                                                        @item.ProductSizeWidth
                                                        <input type="hidden" class="form-control" data-des="尺寸宽-mm" id="ProductSizeWidth" name="ProductSizeWidth" value="@item.ProductSizeWidth">
                                                    </td>
                                                    <td>
                                                        @item.ProductSizeLenth
                                                        <input type="hidden" class="form-control" data-des="尺寸长-mm" id="ProductSizeLenth" name="ProductSizeLenth" value="@item.ProductSizeLenth">
                                                    </td>
                                                    <td>
                                                        @item.ProductUnit
                                                        <input type="hidden" class="form-control" data-des="基本单位" id="ProductUnit" name="ProductUnit" value="@item.ProductUnit">
                                                    </td>
                                                    <td>
                                                        <input type="hidden" class="form-control itemAmount" data-des="数量" id="ProductAmount" name="ProductAmount" value="@item.ProductAmount" readonly="readonly">
                                                        @item.ProductAmount
                                                    </td>
                                                    <td>
                                                        <input type="hidden" class="form-control itemPrice" data-des="价格" id="ProductPrice" name="ProductPrice" value="@item.ProductPrice" readonly="readonly">
                                                        @item.ProductPrice
                                                    </td>
                                                    <td>
                                                        @item.ProductTax
                                                        <input type="hidden" class="form-control" data-des="增值税" id="ProductTax" name="ProductTax" value="@item.ProductTax">
                                                    </td>
                                                    <td>
                                                        @item.TotalMoney
                                                        <input type="hidden" class="form-control itemMoney" data-des="金额" id="TotalMoney" name="TotalMoney" value="@item.TotalMoney.ToString("f2")" readonly="readonly">
                                                    </td>
                                                    <td>
                                                        @cumulativemoney
                                                        <input type="hidden" class="form-control" data-des="累计金额" id="CumulativeMoney" name="CumulativeMoney" value="@cumulativemoney.ToString("f2")" readonly="readonly">
                                                    </td>
                                                </tr>
                                            }
                                        }
                                    </tbody>
                                </table>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">备注</label>
                                <div class="col-sm-9">
                                    <textarea class="form-control" rows="3" placeholder="" name="Memo" id="Memo" readonly="readonly">@Model.Memo</textarea>
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>

                            <div class="form-group col-md-6">
                                <label for="operationName" class="col-sm-3 control-label">操作人</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationName" name="operationName" value="@operationName" readonly="readonly">
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="operationTime" class="col-sm-3 control-label">日期</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="operationTime" name="operationTime" value="@operationTime" readonly="readonly">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            <span id="historyBack" class="btn btn-primary submitbtn">返回</span>
                            @*<a class="btn btn-primary submitbtn" href="@Url.Action("ReceivableQuery", "FinanceCost")">返回</a>*@
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

@section Scripts{
    <script type="text/javascript">
        //日期控件
        $(".Timedatepicker").datepicker({
            autoclose: true,
            language: 'zh', //汉化
            format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
            minView: "month"//选择日期后，不会再跳转去选择时分秒
        });

        $(document).ready(function () {
            $('#footable').footable();
            $('#footable1').footable();
        });

        var type = 1;

        function formsubmit(t) {
            type = t;
            $("#Type").val(t);
            $("#frmedit").submit();
        }

        //$(".okeydown").on("keydown", function () {
        $(document).on("keydown", ".okeydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

        $("#historyBack").click(function () {
            window.history.go(-1);  //返回上一页
            //window.history.back();  //返回上一页
        });

        function duizhangQueryInfo(fid) {
            var options = {
                id: null,
                title: '开票信息',
                width: "100%",
                height: "100%",
                url: "/FinanceCost/FinanceInvoiceLayout?fid=" + fid,
                shade: 0.3,
                btn: ['返回'],
                btnclass: ['btn btn-danger'],
                callBack: null
            }
            $.modalOpen(options);
        }
    </script>
}

